# It was quicker to do this than it was to read through the cmake
# documentation to find out how to set "-Os".
# I lie. I just hate CMake. ~oh look at me i'm being a Professional
# Software Engineer on source files all in a single directory for a
# single embedded target~
# --
# Chris Baird,, <chris.j.baird@gmail.com>

all:	
	arm-none-eabi-gcc \
		-o build.elf \
		-Os -Wall -mcpu=cortex-m3 -mthumb -ffunction-sections -nostartfiles \
		-DSTM32F100C8 -DSTM32F10X_MD_VL -DUSE_STDPERIPH_DRIVER \
		-Wl,--gc-sections -T arm-gcc-link.ld \
		-I cmsis -I cmsis_boot -I stm_lib/inc -I . \
		cmsis_boot/startup/startup_stm32f10x_md_vl.c \
		cmsis_boot/system_stm32f10x.c syscalls/syscalls.c \
		stm_lib/src/stm32f10x_flash.c stm_lib/src/stm32f10x_rcc.c \
		stm_lib/src/stm32f10x_tim.c stm_lib/src/stm32f10x_gpio.c \
		stm_lib/src/stm32f10x_spi.c stm_lib/src/misc.c \
		init.c delay.c radio.c morse.c dht.c main.c
	arm-none-eabi-size build.elf
	arm-none-eabi-objcopy -Obinary build.elf build.bin

clean:
	rm -f build.elf build.bin *.o

flash:
	sudo st-flash --reset write build.bin 0x8000000
